home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ddj0897.zip / AA897.ASC next >
Text File  |  1997-06-20  |  768b  |  36 lines

  1. _Algorithm Alley: Topological Sorting_
  2. by Jonathan Pincus and Jerry Schwarz
  3.  
  4.  
  5. Example 1: 
  6.  
  7. topsort reports (correctly) that there is a cycle after 1 element
  8. a
  9. cycles reports (correctly) that there are two cycles
  10. cycle 0: g f 
  11. cycle 1: d c b 
  12.  
  13. topsortWithCycles reports (correctly) that there is a cycle 
  14. a
  15. d
  16. c
  17. b
  18. e
  19. g
  20. f
  21.  
  22. Example 2: 
  23.  
  24. template<class RandomAccessIterator,
  25.      class InputIterator,
  26.      class OutputIterator>
  27. int
  28. topsort (RandomAccessIterator begin,
  29.          RandomAccessIterator end,     // members being sorted
  30.          InputIterator beginRel,
  31.          InputIterator endRel,         // relations being sorted
  32.          OutputIterator result
  33.          )
  34.  
  35.  
  36.